01 / 05

How do you use cy.intercept() for network requests?

cy.intercept() in Cypress is used to spy on, modify, or stub network requests/responses — perfect for testing without depending on real backend responses.​

cy.intercept() lets you:​
  1. 1

    Monitor (spy): Observe outgoing or incoming HTTP requests

  2. 2

    Stub (mock): Provide fake responses to skip actual API calls

  3. 3

    Modify: Change the request or response on-the-fly

Basic Syntax: